
import 'package:bot_toast/bot_toast.dart';
import 'package:flutter/material.dart';

/*
 * BotToastCall
 * @author: ZhongWb
 * @date: 2019/12/13 11:11
 * @description 调用BotToast插件，使用自定义模板
 **/
class BotToastCall{

  ///todo:  普通文本吐司 默认2秒 默认底下弹出
  ///todo:[seconds]时间 [message]提示  [align]位置 [textStyle]文本样式
  static ShowMessage(String message,{int seconds,Alignment align,Color bg,TextStyle textStyle}){
    BotToast.showText(borderRadius: BorderRadius.circular(5),textStyle:textStyle ?? TextStyle(color: Colors.white) ,contentPadding: EdgeInsets.all(10),contentColor: bg ?? Color(0xff333333),text:message,align:align ?? Alignment(0, 0.8),duration: Duration(seconds: seconds ?? 2));
  }
  ///todo: 图标文本吐司  默认2秒 屏幕居中弹出
  ///todo:[seconds]时间 [message]提示 [img]图片 [textStyle]和[message] 选1 ，text可自定义文本样式
  static ShowCustom({String message,seconds,String img,bg,TextStyle textStyle}){
    BotToast.showAttachedWidget(
        attachedBuilder: (context){
          return _ShowCustomContent(message: message,img: img,textStyle: textStyle);
        },
        duration: Duration(seconds: seconds  ?? 2),
        target: Offset(520, 520),
    );
  }

  ///todo:自定义样式
  ///todo:[message]提示 [img]图标
  static _ShowCustomContent({message,img,TextStyle textStyle}){
    return Center(
      child: Container(
        decoration: BoxDecoration(
          color: Color(0xff333333),
          borderRadius: BorderRadius.circular(6),
        ),
        width: 120,
        height: 120,
        alignment: Alignment.center,
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Image.asset(img ?? "images/package/ok.png",width: 30,height: 30,),
            SizedBox(height: 3,),
            message!=null?Text(message,style: textStyle ?? TextStyle(color: Colors.white,fontSize: 17),) :Container(),
          ],
        ),
      ),
    );
  }
}
